import request from "../../../../plugins/request"

Component({
	properties: {},
	data: {
		bannerList: [],
	},
	methods: {
		bannerClick(e) {
			const item = e.currentTarget.dataset.item
			console.log(item, "item")
			switch (item.bannerType) {
				//跳站内页面
				case 2:
					wx.navigateTo({
						url: item.linkUrl,
					})
					wx.switchTab({
						url: item.linkUrl,
					})
					break
				//跳转到别的小程序
				case 3:
					wx.navigateToMiniProgram({
						appId: item.appId,
						path: item.linkUrl,
						extraData: {},
						envVersion: "release",
					})
					break
			}
		},
	},
	created() {
		//获取banner列表
		request({
			url: "api/wx/get-banner-set",
			errorHandle: true,
			showLoading: true,
		}).then((data) => {
			//为图片连接拼接base64前缀 imageBase
			data.forEach((item) => {
				item.imageBase = "data:image/png;base64," + item.imageBase
			})
			this.setData({
				bannerList: data,
			})
		})
	},
})
